package com.wicket.okrbff.biz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.wicket.okrbff.biz.service.BehaviorTypeService;
import com.wicket.okrbff.biz.service.dto.common.BffBehaviorTypeDto;
import com.wicket.okrbff.biz.service.dto.req.*;
import com.wicket.okrbff.biz.service.dto.res.*;
import com.wicket.okrbff.common.util.RedisUtil;
import com.wicket.okrframework.integration.FwBaseBehaviorTypeClient;
import com.wicket.okrframework.integration.FwBaseInductionRecordClient;
import com.wicket.okrframework.integration.dto.*;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.stream.Collectors;
import com.wicket.okrbff.common.exception.Assert;
import com.wicket.okrbff.biz.service.dto.common.BffBehaviorTypeMenuDto;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@Service
public class BehaviorTypeServiceImpl implements BehaviorTypeService {

    @Resource
    FwBaseBehaviorTypeClient fwBaseBehaviorTypeClient;
    @Resource
    FwBaseInductionRecordClient fwBaseInductionRecordClient;
    @Resource
    private RedisUtil redisUtil;



    /**
   * B1-1查询行为类型列表(边界)[1412]
   * gen by moon at 8/10/2022, 3:35:26 AM
   */
    @Trace(operationName = "B1-1查询行为类型列表(边界)")
    @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Override
  public BffQueryBehaviorTypeListBorderRespDto queryBehaviorTypeListBorder(BffQueryBehaviorTypeListBorderReqDto reqDto){
      
       
       QueryBehaviorTypeListRespDto queryBehaviorTypeListRespDto_1 = null;
//步骤0: D1-1查询行为类型列表 - queryBehaviorTypeList
     QueryBehaviorTypeListRespDto queryBehaviorTypeListRespDto = null;
    QueryBehaviorTypeListReqDto queryBehaviorTypeListReqDto=new QueryBehaviorTypeListReqDto();
  queryBehaviorTypeListReqDto.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:32572_1
if(reqDto!=null){
      queryBehaviorTypeListReqDto.setBehaviorTypeName(reqDto.getBehaviorTypeName());//sourceId:35139_1
    }
  
    /*D1-1查询行为类型列表[719]   */
    Assert.isNull(queryBehaviorTypeListReqDto.getSubjectLifeCycle(),"B1-1查询行为类型列表(边界)-D1-1查询行为类型列表-主体生命周期不能为空",false);
      queryBehaviorTypeListRespDto = fwBaseBehaviorTypeClient.queryBehaviorTypeList(queryBehaviorTypeListReqDto).getData();
      
      queryBehaviorTypeListRespDto_1 = queryBehaviorTypeListRespDto;
    
BffQueryBehaviorTypeListBorderRespDto retData = new BffQueryBehaviorTypeListBorderRespDto();
  if(queryBehaviorTypeListRespDto_1!=null){
      retData.setBehaviorTypeList(queryBehaviorTypeListRespDto_1.getBehaviorTypeList().stream().map(item -> BeanUtil.toBean(item, BffBehaviorTypeDto.class)).collect(Collectors.toList()));//sourceId:32573_1
    }
  

  
  
return retData;
  }
/**
   * B1-1查询行为类型菜单列表(边界)[4339]
   * gen by moon at 10/8/2022, 3:10:47 AM
   */
    @Trace(operationName = "B1-1查询行为类型菜单列表(边界)")
    @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Override
  public BffQueryBehaviorTypeMenuListBorderRespDto queryBehaviorTypeMenuListBorder(BffQueryBehaviorTypeMenuListBorderReqDto reqDto){
      
       
       QueryBehaviorTypeMenuListBorderRespDto queryBehaviorTypeMenuListBorderRespDto_1 =null;
//步骤0: D1-1查询行为类型菜单列表(边界) - queryBehaviorTypeMenuListBorder
     QueryBehaviorTypeMenuListBorderRespDto queryBehaviorTypeMenuListBorderRespDto = null;
    QueryBehaviorTypeMenuListBorderReqDto queryBehaviorTypeMenuListBorderReqDto=new QueryBehaviorTypeMenuListBorderReqDto();
  if(reqDto!=null){
      queryBehaviorTypeMenuListBorderReqDto.setBizSceneCode(reqDto.getBizSceneCode());//SimpleFieldAssign//sourceId:286608_1
    }
  
    /*D1-1查询行为类型菜单列表(边界)[4338]   */
    Assert.isNull(queryBehaviorTypeMenuListBorderReqDto.getBizSceneCode(),"B1-1查询行为类型菜单列表(边界)-D1-1查询行为类型菜单列表(边界)-业务场景标识不能为空",false);
      queryBehaviorTypeMenuListBorderRespDto = fwBaseBehaviorTypeClient.queryBehaviorTypeMenuListBorder(queryBehaviorTypeMenuListBorderReqDto).getData();
      
      
      queryBehaviorTypeMenuListBorderRespDto_1 = queryBehaviorTypeMenuListBorderRespDto;
    
BffQueryBehaviorTypeMenuListBorderRespDto retData = new BffQueryBehaviorTypeMenuListBorderRespDto();
  if(queryBehaviorTypeMenuListBorderRespDto_1!=null){
      retData.setBehaviorTypeMenuList(queryBehaviorTypeMenuListBorderRespDto_1.getBehaviorTypeMenuList().stream().map(item -> BeanUtil.toBean(item, BffBehaviorTypeMenuDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:286611_1
    }
  

  
  
return retData;
  }
    //
}
